Formal parameters in VectorScript refer to the parameters which are defined in the parameter lists of built-in or user-defined functions. Formal parameters provide the data interface “template” for the function, indicating the order and typing of the values that will be passed in and out of the function call. Actual parameters refer to the expressions or values that are passed by a function in the body of the script. For example, in the declaration statement of the subroutine
SumOfSquares:
the subroutine procedure has two actual parameters, n and
sum. These actual parameters contain the data used and returned by the function call. Checking the
VAR block of the script, notice that the data types of the two identifiers match the types found in the formal parameter list.
Value parameters in VectorScript are parameters which are used to pass data values into a subroutine. Within the subroutine, they act just like local variables except that they obtain their initial value from a corresponding actual parameter in the parameter list. In the
SumOfSquares example:
the identifier limit is a value parameter, or more fully, a formal value parameter. In the function call of the main script:
the value contained in the variable n would be assigned to the value parameter
limit for use within the subroutine.
Variable parameters in VectorScript are the opposite of value parameters—they are used to pass data values out of a subroutine. They are denoted by the
VAR keyword which precedes them in the parameter list, and like value parameters, act as local variables within the subroutine. In the
SumOfSquares example:
the identifier result is a formal variable parameter, which can be used within the subroutine script code to pass values back to the calling code. In the function call of the main script:
the value contained in the variable parameter result would be assigned to the variable
sum when the subroutine finished execution.